package day8;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//两种排序方法
public class oj1 {
    public static void main(String[] args) throws IOException {
        //从字符流中读取文本并缓存
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bi.readLine());
        String[] str = new String[n];
        for(int i = 0; i < str.length;i++) {
            str[i] = bi.readLine();
        }

        if(isSortLength(str) && isSortZiDian(str)) {
            System.out.println("both");
        } else if(isSortLength(str)) {
            System.out.println("lengths");
        } else if(isSortZiDian(str)) {
            System.out.println("lexicographically");
        } else {
            System.out.println("none");
        }

    }
    public static boolean isSortZiDian(String[] str) {
        for(int i = 0; i < str.length - 1; i++) {
            if(str[i].compareTo(str[i + 1]) > 0) {
                return false;
            }
        }
        return true;
    }
    public static boolean isSortLength(String[] str) {
        for(int i = 0; i < str.length - 1; i++) {
            if(str[i].length() > str[i + 1].length()) {
                return false;
            }
        }
        return true;
    }
}
